/**
 * @description:
 * @param {string} name string
 * @param {object} value object
 * @Description :设置读取删除本地sessionStorage / localStorage缓存
 * @param {*} type 0 为默认sessionStorage 1为localStorage
 * @return {*}
 */

export function getInfo(name: string, type = 0) {
    const key = type === 0 ? sessionStorage : localStorage;
    return JSON.parse(key.getItem(name) as string) || null;
}

export function setInfo(name: string, value: object, type = 0) {
    const key = type === 0 ? sessionStorage : localStorage;
    return key.setItem(name, JSON.stringify(value));
}

export function removeInfo(name: string, type = 0) {
    const key = type === 0 ? sessionStorage : localStorage;
    return key.removeItem(name);
}
